<!-- 个人信息 -->
<template>
	<view>
		<view class="info" >
			<view>
				<view class="info_part" @tap.stop="jump('/pages/user/info/edit/index')">
					<view class="info_name">上传头像</view>
					<view class="circle pr">
						<view class="user_img">
							<image :src="user.pic_url"></image>
						</view>
						<view class="arrow_right">
							<image :src="arrow_right" mode=""></image>
						</view>
					</view>
				</view>
				<view class="info_part">
					<view class="info_name">用户昵称</view>
					<view class="info_text">{{ user.nickname }}</view>
				</view>
				<view class="info_part">
					<view class="info_name">登入账户</view>
					<view class="info_text">{{ user.mobile || '未绑定'}}</view>
				</view>
				<view class="info_part">
					<view class="info_name">绑定手机</view>
					<view class="info_text">{{ user.mobile }}</view>
				</view>
				<view class="info_part pr" @tap.stop="jump('/pages/user/info/address/index')">
					<view class="info_name">送货地址</view>
					<view class="info_text paddingRirht">{{ address || '请填写送货地址' }}</view>
					<image class="pa right" :src="arrow_right"></image>
				</view>
			</view>
			<view class="loginout">
				<btn :title="btn" @jump="jumpLogin(login_url)"></btn>
			</view>
		</view>
		<!-- 让父标签 0宽 0高 隐藏溢出 -->
		<view style="width:0rpx;height:0rpx; overflow:hidden">
			<canvas type="2d" id="canvas"></canvas>
		</view>
	</view>
</template>
<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	import btn from '../components/btn/index.vue';
	export default {
		components: {
			btn
		},
		data() {
			return {
				login_url: "/pages/login/index",
				address_url: "/pages/user/info/address/index",
				btn: '退出登录',
				arrow_right: this.imgUrl + 'arrow_right.png',
				address: '',
			};
		},
		computed: {
			...mapState({
				user: state => state.user.user,              // 获取用户信息
				selected: state => state.address.selected,   // 获取选择地址
			}),
		},
		onUnload() {
			// 区别订单提交地址的返回页面
			this.$store.dispatch('user/get_placeType', 0 )
		},
		mounted() {
			// 个人信息地址追加一个状态，判断页面返回结果
			this.$store.dispatch('user/get_placeType', 1 )
			this.address = this.user.address + this.user.address_detail
		},
		onShow() {
			// 显示获取页面地址
			this.address = this.selected.address  + this.selected.address_detail
		},
		methods: {
			//修改头像
			jump(path, params) {
				this.$Router.push({
					path: path,
					params: params
				})
			},
			// 退出登入
			jumpLogin(path, params) {
				this.$api('auth.loginOut');
			},
		}
	};
</script>
<style scoped lang='scss'>
	@import './index.scss'
</style>
